<?php
session_start();
if (isset($_POST['openid']) && !empty($_POST['openid'])){
    include '../c/config.php';
    $mysqli = new mysqli($dbhost, $dbuser, $dbpwd, $dbName);
    if (!$mysqli->set_charset("utf8")) {}
    $openid=addslashes(trim($_POST['openid']));
    
    $step=1;
    $query=$mysqli->query("SELECT id FROM qdui where openid='".$openid."' limit 0,1 ");
    if($query->num_rows>0){
        $step=2;
    }
    $query=$mysqli->query("SELECT id FROM joinqiu where openid='".$openid."' limit 0,1 ");
    if($query->num_rows>0){
        $step=2;
    }
    
    $msgTxt=$msgTitle='';
    if(1 == $step){
        $query=$mysqli->query("SELECT id,fromid,type FROM message where isread=0 and myid='".$openid."' and type=3 limit 0,1 ");
        if($query->num_rows>0){
            $getMessage=$query->fetch_assoc();
            if (3 == $getMessage['type']){
                $query=$mysqli->query("SELECT name FROM qdui where openid='".$getMessage['fromid']."' limit 0,1 ");
                if($query->num_rows>0){
                    $getQui=$query->fetch_assoc();
                    $msgTitle='未通过提醒';
                    $msgTxt='您未通过'.$getQui['name'].'的申请';
                }
                $mysqli->query("update message set isread=1 where id='".$getMessage['id']."'  ");
            }
        }
        
        
        
    }
    
    
    $mysqli->close();
    echo json_encode(array('s'=>$step,'mt'=>$msgTxt,'mbt'=>$msgTitle));
}

